package com.yonyou.pmclouds.safetypatrol.process;

import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.basecom.exception.BuziExCodeConst;
import com.yonyou.pmclouds.safetypatrol.entity.SafetypatrolVO;
import com.yonyou.pmclouds.safetypatrol.mapper.SafetypatrolMapper;

/**
 * @author 徐老板
 * @date 2020/4/16   19:03
 */

public class SafetypatrolInsertCheckProcess implements SingleProcessor<SafetypatrolVO> {

    private SafetypatrolMapper safetypatrolMapper;

    public SafetypatrolInsertCheckProcess(SafetypatrolMapper safetypatrolMapper) {
        this.safetypatrolMapper = safetypatrolMapper;
    }


    @Override
    public void process(SafetypatrolVO vo, SafetypatrolVO orig) throws BusinessException {
        Integer count =safetypatrolMapper.findByStandardnameAndpkTenant(vo.getStandardName(),vo.getPkTenant());
        if (count!=null && count>0){
            throw new BusinessException("已存在相同的安全标准 请修改", BuziExCodeConst.CODE_NAME_CODE_DUPLICATE);
        }
    }
}
